<?php


abstract class BaseSmsService extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $keyword;


	
	protected $service_number;


	
	protected $description;


	
	protected $first_param;


	
	protected $last_param;


	
	protected $invalid_number_msg;


	
	protected $invalid_content_msg;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getKeyword()
	{

		return $this->keyword;
	}

	
	public function getServiceNumber()
	{

		return $this->service_number;
	}

	
	public function getDescription()
	{

		return $this->description;
	}

	
	public function getFirstParam()
	{

		return $this->first_param;
	}

	
	public function getLastParam()
	{

		return $this->last_param;
	}

	
	public function getInvalidNumberMsg()
	{

		return $this->invalid_number_msg;
	}

	
	public function getInvalidContentMsg()
	{

		return $this->invalid_content_msg;
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = SmsServicePeer::ID;
		}

	} 
	
	public function setKeyword($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->keyword !== $v) {
			$this->keyword = $v;
			$this->modifiedColumns[] = SmsServicePeer::KEYWORD;
		}

	} 
	
	public function setServiceNumber($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->service_number !== $v) {
			$this->service_number = $v;
			$this->modifiedColumns[] = SmsServicePeer::SERVICE_NUMBER;
		}

	} 
	
	public function setDescription($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->description !== $v) {
			$this->description = $v;
			$this->modifiedColumns[] = SmsServicePeer::DESCRIPTION;
		}

	} 
	
	public function setFirstParam($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->first_param !== $v) {
			$this->first_param = $v;
			$this->modifiedColumns[] = SmsServicePeer::FIRST_PARAM;
		}

	} 
	
	public function setLastParam($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->last_param !== $v) {
			$this->last_param = $v;
			$this->modifiedColumns[] = SmsServicePeer::LAST_PARAM;
		}

	} 
	
	public function setInvalidNumberMsg($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->invalid_number_msg !== $v) {
			$this->invalid_number_msg = $v;
			$this->modifiedColumns[] = SmsServicePeer::INVALID_NUMBER_MSG;
		}

	} 
	
	public function setInvalidContentMsg($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->invalid_content_msg !== $v) {
			$this->invalid_content_msg = $v;
			$this->modifiedColumns[] = SmsServicePeer::INVALID_CONTENT_MSG;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->keyword = $rs->getString($startcol + 1);

			$this->service_number = $rs->getString($startcol + 2);

			$this->description = $rs->getString($startcol + 3);

			$this->first_param = $rs->getString($startcol + 4);

			$this->last_param = $rs->getString($startcol + 5);

			$this->invalid_number_msg = $rs->getString($startcol + 6);

			$this->invalid_content_msg = $rs->getString($startcol + 7);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 8; 
		} catch (Exception $e) {
			throw new PropelException("Error populating SmsService object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(SmsServicePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			SmsServicePeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(SmsServicePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = SmsServicePeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += SmsServicePeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = SmsServicePeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = SmsServicePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getKeyword();
				break;
			case 2:
				return $this->getServiceNumber();
				break;
			case 3:
				return $this->getDescription();
				break;
			case 4:
				return $this->getFirstParam();
				break;
			case 5:
				return $this->getLastParam();
				break;
			case 6:
				return $this->getInvalidNumberMsg();
				break;
			case 7:
				return $this->getInvalidContentMsg();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = SmsServicePeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getKeyword(),
			$keys[2] => $this->getServiceNumber(),
			$keys[3] => $this->getDescription(),
			$keys[4] => $this->getFirstParam(),
			$keys[5] => $this->getLastParam(),
			$keys[6] => $this->getInvalidNumberMsg(),
			$keys[7] => $this->getInvalidContentMsg(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = SmsServicePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setKeyword($value);
				break;
			case 2:
				$this->setServiceNumber($value);
				break;
			case 3:
				$this->setDescription($value);
				break;
			case 4:
				$this->setFirstParam($value);
				break;
			case 5:
				$this->setLastParam($value);
				break;
			case 6:
				$this->setInvalidNumberMsg($value);
				break;
			case 7:
				$this->setInvalidContentMsg($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = SmsServicePeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setKeyword($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setServiceNumber($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setFirstParam($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setLastParam($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setInvalidNumberMsg($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setInvalidContentMsg($arr[$keys[7]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(SmsServicePeer::DATABASE_NAME);

		if ($this->isColumnModified(SmsServicePeer::ID)) $criteria->add(SmsServicePeer::ID, $this->id);
		if ($this->isColumnModified(SmsServicePeer::KEYWORD)) $criteria->add(SmsServicePeer::KEYWORD, $this->keyword);
		if ($this->isColumnModified(SmsServicePeer::SERVICE_NUMBER)) $criteria->add(SmsServicePeer::SERVICE_NUMBER, $this->service_number);
		if ($this->isColumnModified(SmsServicePeer::DESCRIPTION)) $criteria->add(SmsServicePeer::DESCRIPTION, $this->description);
		if ($this->isColumnModified(SmsServicePeer::FIRST_PARAM)) $criteria->add(SmsServicePeer::FIRST_PARAM, $this->first_param);
		if ($this->isColumnModified(SmsServicePeer::LAST_PARAM)) $criteria->add(SmsServicePeer::LAST_PARAM, $this->last_param);
		if ($this->isColumnModified(SmsServicePeer::INVALID_NUMBER_MSG)) $criteria->add(SmsServicePeer::INVALID_NUMBER_MSG, $this->invalid_number_msg);
		if ($this->isColumnModified(SmsServicePeer::INVALID_CONTENT_MSG)) $criteria->add(SmsServicePeer::INVALID_CONTENT_MSG, $this->invalid_content_msg);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(SmsServicePeer::DATABASE_NAME);

		$criteria->add(SmsServicePeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setKeyword($this->keyword);

		$copyObj->setServiceNumber($this->service_number);

		$copyObj->setDescription($this->description);

		$copyObj->setFirstParam($this->first_param);

		$copyObj->setLastParam($this->last_param);

		$copyObj->setInvalidNumberMsg($this->invalid_number_msg);

		$copyObj->setInvalidContentMsg($this->invalid_content_msg);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new SmsServicePeer();
		}
		return self::$peer;
	}

} 